import {useRef, useState} from 'react';
import {PanResponder} from 'react-native';

export default () => {
  const [scrollEnabled, setScrollEnabled] = useState(true);
  const panResponder = useRef(
    PanResponder.create({
      onStartShouldSetPanResponder: () => {
        setScrollEnabled(false); // 触摸图表时禁止 ScrollView 滚动
        return true;
      },
      onPanResponderRelease: () => {
        setScrollEnabled(true); // 释放后恢复 ScrollView 滚动
      },
    }),
  ).current;
  return {
    scrollEnabled,
    panResponder,
  };
};
